<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr XMLNS:MSHelp = "http://msdn.microsoft.com/mshelp" xmlns:ddue = 
"http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink = 
"http://www.w3.org/1999/xlink" xmlns:tool = "http://www.microsoft.com/tooltip"
XMLNS:[default] http://ddue.schemas.microsoft.com/authoring/2003/5 =
"http://ddue.schemas.microsoft.com/authoring/2003/5"><HEAD>
  <TITLE>Windows Azure Service Bus Transactions Sample</TITLE>
  <META content="text/html; CHARSET=utf-8" http-equiv=Content-Type></META>
  <META name=save content=history></META>
  <LINK rel=stylesheet type=text/css
  href="../../../CommonFiles/Classic.css"></LINK>

  <META name=GENERATOR content="MSHTML 8.00.6001.18783">
    <style type="text/css">
      .style2 {
      font-family: monospace;
      font-size: small;
      color: #000000;
      }
      </style>
  </HEAD>
<BODY>
  <DIV id=header>
    <TABLE id=topTable width="100%">
      <TBODY>
        <TR id=headerTableRow1>
          <TD align=left>
            <SPAN id=runningHeaderText></SPAN>
          </TD>
        </TR>
        <TR id=headerTableRow2>
          <TD align=left>
            <SPAN id=nsrTitle>Windows Azure Service Bus Transactions Sample</SPAN>
          </TD>
        </TR>
        <TR id=headerTableRow3>
          <TD></TD>
        </TR>
      </TBODY>
    </TABLE>
  </DIV>
  <DIV id=mainSection>
    <DIV id=mainBody>
      <p>
        This sample demonstrates how to use the Windows Azure Service Bus messaging features within a transaction scope in order to ensure batches of messaging operations are committed atomically.
        See the Service Bus documentation for more information about the Service Bus before exploring the samples.
      </p>
      <p>
        This sample demonstrates: sending and completing messages within a transaction scope; committing and aborting transactions.
      </p>
      <H2 class=heading>Prerequisites</H2>
      <DIV id=sectionSection0 class=section>
        <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
          <P xmlns="">
            If you haven't already done so, please read the release notes
            document that explains how to sign up for a Windows Azure
            account and how to configure your environment.
          </P>
        </content>
      </DIV>
        <H2 class=heading>Sample Flow</H2>
      <DIV id=sectionSection1 class="section">
        <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
            <p>The sample flows in the following manner:</p>
                <ol>
                  <li>Create a new queue on the Service Bus;</li>
                  <li>Send and complete messages within a transaction scope:
                  <ol>
	                  <li>Send a plain text message to the newly created queue;</li>
	                  <li>Peek lock the message from the queue;</li>
	                  <li>Within a transaction scope, send a response message;</li>
                      <li>Within a transaction scope, complete the initial message;</li>
                      <li>Complete the transaction scope;</li>
                      <li>Receive the response message.</li>
                  </ol>
                  </li>
                  <li>Send and complete messages within a transaction scope that rolls back:
                  <ol>
	                  <li>Send a plain text message to the queue;</li>
	                  <li>Peek lock the message from the queue;</li>
	                  <li>Within a transaction scope, send a response message;</li>
                      <li>Within a transaction scope, complete the initial message;</li>
                      <li>Abandon the transaction scope;</li>
                      <li>Receive from the queue - since the transaction was not completed, the response message is not in the queue and the initial message is returned to the queue when its peek lock times out.</li>
                  </ol>
                  </li>
                  <li>Clean up resources associated with the sample.</li>
                </ol>
          </content>
      </DIV>
    </DIV>
    <H2 class=heading>Running the Sample</H2>
    <DIV id=DIV1 class=section>
      <content
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">

        <P xmlns="">
          To run the sample:
        </P>
            <ol>
	          <li>Build and run the sample in Visual Studio.</li>
              <li>When prompted, enter your Service Bus Namespace, Issuer Name and Issuer Key.</li>
            </ol>
          <P xmlns="">
          <B>Expected Output</B>
        </P>
        <DIV class=code xmlns="">
          <SPAN codeLanguage="other">
            <TABLE cellSpacing=0 cellPadding=0 width="100%">
              <TBODY>
                <TR>
                  <TD colSpan=2>
                    <PRE class="style2">
Service Namespace: &lt;Your Namespace&gt;
Issuer Name: owner
Issuer Secret: &lt;Your Secret Key&gt;

Creating Queues...

Scenario 1: Send/Complete in a Transaction and then Complete
Sending Message 'Message 1'
Peek-Lock the Message... Message 1
Inside Transaction 5378d67d-19f1-4d27-affa-3e93841be2aa:1
Sending Reply in a Transaction
Completing message in a Transaction
Marking the Transaction Scope as Completed
Receive the reply... Reply To - Message 1

Press [Enter] to move to the next scenario.


Scenario 2: Send/Complete in a Transaction and do not Complete
Sending Message 'Message 2'
Peek-Lock the Message... Message 2
Inside Transaction 5378d67d-19f1-4d27-affa-3e93841be2aa:2
Sending Reply in a Transaction
Completing message in a Transaction
Exiting the transaction scope without committing...
Receive the request again (this can take a while, because we're waiting for the
PeekLock to timeout)... Message 2

Press [Enter] to exit.
                    </PRE>
                  </TD>
                </TR>
              </TBODY>
            </TABLE>
          </SPAN>
        </DIV>
      </content>
    </DIV>
    <!--[if gte IE 5]><tool:tip avoidmouse="false" element="languageFilterToolTip"></tool:tip><![endif]-->
  </DIV>
    <hr />
    Did you find this information useful?
    <a href="http://go.microsoft.com/fwlink/?LinkID=155664">
      Please send your suggestions and comments about the documentation.
    </a>
  </P>
  </DIV>
</BODY></HTML>
